home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Copyright (C) 1997-2000 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //<doc>
- //<name editAttrLimits>
- //<owner "Alias|WaveFront Unsupported">
- //<synopsis>
- // void editAttrLimits(string $attr, float $min, float $max)
- //<keywords>
- // edit attribute limits min max
- //<related addAttr>
- //
- //<description>
- // Edit the attribute min and max of dynamic attributes.
- //
- //<flags>
- // string $attr Attribute to be altered
- // float $min New attribute minimum
- // float $max New attribute maximum
- //
- //<examples>
- // createNode -n sinNode transform;
- // addAttr -at double -min 0.0 -max 2.0 -ln sinValue;
- // attributeQuery -r -n sinNode sinValue;
- // // Result: 0 2 //
- // editAttrLimits( "sinNode.sinValue", -1.0, 1.0 );
- // attributeQuery -r -n sinNode sinValue;
- // // Result: -1 1 //
- //
- //<notes>
- // This command only works on numeric type attributes that can have
- // limits defined. No checking is performed to verify the attribute
- // type so check types before calling it.
- //
- //</doc>
- //
- global proc editAttrLimits (string $objectAttr, float $min, float $max)
- {
- // this script will allow the user to edit the min and max value of an
- // attribute
-
- // first find out what connections are going into and out of the object
- $input = `listConnections -source true -d false -p true $objectAttr`;
- $output = `listConnections -source false -d true -p true $objectAttr`;
-
- // get the current value of the attr
- $val = `getAttr $objectAttr`;
-
- // break the connections if they exist
- string $dest;
- if (size($input) > 0)
- {
- disconnectAttr $input[0] $objectAttr;
- }
- for( $dest in $output )
- {
- disconnectAttr $objectAttr $dest;
- }
-
- // now tokenize $objectAttr in order to get it's individual parts
- string $parts[2];
- tokenize ($objectAttr, ".", $parts);
- $object = $parts[0];
- $attr = $parts[1];
-
- // get the type of attribute this is
- $type = `getAttr -type $objectAttr`;
-
- // delete the attribute
- deleteAttr -at $attr $object;
-
- // re-create the attribute with the new min/max
- addAttr -at $type -ln $attr -min $min -max $max $object;
-
- // set the value to be what it used to be
- setAttr $objectAttr $val;
-
- // remake the connections
- if (size($input) > 0)
- {
- connectAttr $input[0] $objectAttr;
- }
- for( $dest in $output )
- {
- connectAttr $objectAttr $output;
- }
- }
-